package com.qf.lanzhou.blog.api.controller.PageBreak;

import com.qf.lanzhou.blog.api.controller.BaseServletPost;
import com.qf.lanzhou.blog.api.controller.PageBreak.ArticlePaginationServlet;
import com.qf.lanzhou.blog.api.pojo.entity.Page;
import com.qf.lanzhou.blog.api.service.ArticlePaginationService;
import com.qf.lanzhou.blog.api.service.impl.ArticlePaginationServicelmpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @author jack
 * 尾页跳转服务器
 */
@WebServlet("/lastPage.do")
public class LastPageServlet extends BaseServletPost {
    private ArticlePaginationService aps = new ArticlePaginationServicelmpl();
    private Page page = new Page(1);
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("尾页服务器");
        //先拿到总页数
        Integer i = aps.getTotalCounts();
        page.setTotalCounts(i);
        //直接跳转到该页
        ArticlePaginationServlet.numPage = page.getTotalPage();
        List list = aps.Pagination(page.getTotalPage());
        successResultWrite(list,resp);
    }
}
